//
//  AppDelegate.m
//  Beauty
//
//  Created by Snow on 16/8/26.
//  Copyright © 2016年 Snow. All rights reserved.
//

#import "AppDelegate.h"
#import "GXMacro.h"
#import "MyTabBarController.h"
#import "LTIntroductionViewController.h"
@interface AppDelegate ()

@property(nonatomic, strong) LTIntroductionViewController *firstLog;//封装的引导页
@end

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    self.window = [[UIWindow alloc] initWithFrame:SCREEN_RECT];
    _window.backgroundColor = [UIColor whiteColor];
    [_window makeKeyAndVisible];
    MyTabBarController *root = [[MyTabBarController alloc] init];
    _window.rootViewController = root;
    //启动页延时
    [NSThread sleepForTimeInterval:2];
    //引导页
    NSString *firstLog = [[NSUserDefaults standardUserDefaults] objectForKey:@"firstLog"];
    
    //如果是第一次登陆
    if (![firstLog isEqualToString:@"YES"]) {
        NSArray *main = @[@"启动页01", @"启动页02", @"启动页03", @"启动页04"];
        
        NSArray *back = @[@"nil", @"nil", @"nil", @"nil"];
        
        self.firstLog = [[LTIntroductionViewController alloc]initWithCoverImageNames:main backgroundImageNames:back];
        
        [self.window addSubview:self.firstLog.view];
        
        //记录状态
        [[NSUserDefaults standardUserDefaults] setObject:@"YES" forKey:@"firstLog"];
    }
    //点击button
    __weak  AppDelegate *weakSelf = self;
    self.firstLog.didSelectedEnter = ^(){
        [weakSelf.firstLog.view removeFromSuperview];
        
        weakSelf.firstLog.view = nil;
    };
    
    return YES;
}

- (void)applicationWillResignActive:(UIApplication *)application {
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

- (void)applicationDidEnterBackground:(UIApplication *)application {
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application {
    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

- (void)applicationWillTerminate:(UIApplication *)application {
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

@end
